package jedis;

import com.alibaba.fastjson.JSONObject;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.Transaction;

public class JedisTrac {
    public static void main(String[] args) {
        Jedis jedis = new Jedis("106.55.170.35", 6379);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("hello", "world");
        jsonObject.put("name", "qxf");

        Transaction transaction = jedis.multi();
        String result = jsonObject.toJSONString();
        int error = 1 / 0;
        try {
            transaction.set("user1", result);
            transaction.set("user2", result);
            transaction.exec();
        } catch (Exception e) {
            transaction.discard();
            e.printStackTrace();
        } finally {
            System.out.println(jedis.get("user1"));
            System.out.println(jedis.get("user2"));
            jedis.close();
        }
    }
}
